package edu.snake.implement.model.character.state;

import edu.snake.core.model.character.Character;
import edu.snake.core.model.character.CharacterState;
import edu.snake.core.model.character.StateCharacter;
import edu.snake.implement.model.character.iterator.NullIterator;

import java.util.Iterator;


public class CharacterStateNotElement implements StateCharacter {
    private static final String STRING_EXCEPTION = "This character state %s is not supported %s operation.";
    private final Character character;
    private final CharacterState state = CharacterState.NOT_ELEMENT;

    public CharacterStateNotElement(Character character) {
        this.character = character;
    }

    @Override
    public CharacterState getState() {
        return state;
    }

    @Override
    public void add(Character character) {
        throw new UnsupportedOperationException(String.format(STRING_EXCEPTION, character.getState().toString(), "ADD "));
    }

    @Override
    public void remove(Character character) {
        throw new UnsupportedOperationException(String.format(STRING_EXCEPTION, character.getState().toString(), "REMOVE "));
    }

    @Override
    public Character getChild(int i) {
        throw new UnsupportedOperationException(String.format(STRING_EXCEPTION, character.getState().toString(), "GET_CHILD "));
    }

    @Override
    public Iterator<Character> iterator() {
        return new NullIterator();
    }

    @Override
    public int size() {
        return 1;
    }

    @Override
    public String toString() {
        return "CharacterStateNotElement{" +
                "character=" + character +
                ", state=" + state +
                '}';
    }
}
